// pages/courselist/courselist.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    courselist:"",
    options:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getData(options.id)
    this.setData({
      options
    })
  },
  getData(teacherid) {
    let that = this
    wx.request({
        url: 'http://localhost:8080/Examination_System_war/wxappeal/wxShowAppeal',
        data: {
          teacherid
        },
        header: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'GET',
        dataType: 'json',
        responseType: 'text',
        success: (result) => {
            console.log(result)
            that.setData({
                courselist:result.data.appealList
            })
        },
        fail: () => { },
        complete: () => { }
      });
      
},
  goPage(e) {
    let id =  e.currentTarget.dataset.operation.id
    wx.navigateTo({
      url: '/pages/coursedetail/index?id=' + id
    });
},
back(e) {
  let that = this;
  let id =  e.currentTarget.dataset.operation.id
  wx.showModal({
    title: '确认是否驳回',
    content: '',
    showCancel: true,
    cancelText: '取消',
    cancelColor: '#000000',
    confirmText: '确定',
    confirmColor: '#3CC51F',
    success: (result) => {
      if (result.confirm) {
        wx.request({
          url: 'http://localhost:8080/Examination_System_war/wxappeal/updateAppeal',
          data: {
            id,
            status : 3
          },
          header: { 'content-type': 'application/x-www-form-urlencoded' },
          method: 'POST',
          dataType: 'json',
          responseType: 'text',
          success: (result) => {
              that.onLoad(that.data.options)
          },
          fail: () => { },
          complete: () => { }
        });
      } else{

      }
    },
    fail: () => {},
    complete: () => {}
  });
    

},
complete(e) {
  let that = this;
  let id =  e.currentTarget.dataset.operation.id
  wx.showModal({
    title: '确认是否通过',
    content: '',
    showCancel: true,
    cancelText: '取消',
    cancelColor: '#000000',
    confirmText: '确定',
    confirmColor: '#3CC51F',
    success: (result) => {
      if (result.confirm) {
        wx.request({
          url: 'http://localhost:8080/Examination_System_war/wxappeal/updateAppeal',
          data: {
            id,
            status : 2
          },
          header: { 'content-type': 'application/x-www-form-urlencoded' },
          method: 'POST',
          dataType: 'json',
          responseType: 'text',
          success: (result) => {
              that.onLoad(that.data.options)
          },
          fail: () => { },
          complete: () => { }
        });
      } else{

      }
    },
    fail: () => {},
    complete: () => {}
  });
    

}
})